package com.atguigu.srb.sms.config;


import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "aliyun.sms")
public class SmsProperties implements InitializingBean {
    // 根据配置文件的后缀自动赋值(私有)
    private String regionId;
    private String keyId;
    private String keySecret;
    private String templateCode;
    private String signName;

    // 静态类默认没有值
    public static String REGION_Id;
    public static String KEY_ID;
    public static String KEY_SECRET;
    public static String TEMPLATE_CODE;
    public static String SIGN_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        // 在所有私有属性赋值之后执行
        this.REGION_Id = regionId;
        this.KEY_ID = keyId;
        this.KEY_SECRET = keySecret;
        this.TEMPLATE_CODE = templateCode;
        this.SIGN_NAME = signName;

    }
}
